﻿using System;
using System.Collections.Generic;
using System.Linq;
namespace ProyectoDeTesis.Controladores
{
    public class PistaController
    {

        public List<Pista> buscarPistas()
        {
            List<Pista> listaPista = new List<Pista>();
            var db = new Bd_tesisDataContext();
            try
            {
                var query = from p in db.Pista
                            select p;
                listaPista = query.ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return listaPista;
        }

        public Pista buscarPistaxId(int pista_id)
        {
            Pista pista = new Pista();
            var db = new Bd_tesisDataContext();
            try
            {
                pista = db.Pista.Single(u => u.id == pista_id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return pista;
        }

        public Pista buscarPistaxNombre(string valor)
        {
            Pista pista = new Pista();
            var db = new Bd_tesisDataContext();
            try
            {
                pista = db.Pista.Single(u => u.nombre == valor);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return pista;
        }
    }
}
